| Conditions | 1 |
| Paths | 0 |
| Total Lines | 29 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | import { ACTION_PREFIX, ACTION_TYPES, HISTORY_METHODS} from './constants'; |
||
| 4 | export default ({ history, routeParser }) => ({ dispatch, getState }) => next => action => { |
||
| 5 | |||
| 6 | if (action.type.indexOf(ACTION_PREFIX) === 0 && action.type !== ACTION_TYPES.LOCATION_CHANGED) { |
||
| 7 | |||
| 8 | if (action.type === ACTION_TYPES.GO_TO_ROUTE) { |
||
| 9 | action.type = ACTION_TYPES.PUSH; |
||
| 10 | action.payload = routeParser(action.payload); |
||
| 11 | } |
||
| 12 | |||
| 13 | if ([ACTION_TYPES.PUSH, ACTION_TYPES.REPLACE].includes(action.type)) { |
||
| 14 | |||
| 15 | action.payload = typeof action.payload === 'string' ? parsePath(action.payload) : action.payload; |
||
| 16 | |||
| 17 | const sameLocation = history.location.pathname === action.payload.pathname |
||
| 18 | && history.location.search === action.payload.search |
||
| 19 | && history.location.hash === action.payload.hash; |
||
| 20 | |||
| 21 | action.type = sameLocation ? ACTION_TYPES.REPLACE : action.type; |
||
| 22 | } |
||
| 23 | |||
| 24 | if (HISTORY_METHODS[action.type]) { |
||
| 25 | history[HISTORY_METHODS[action.type]](action.payload); |
||
| 26 | } |
||
| 27 | |||
| 28 | return; |
||
| 29 | } |
||
| 30 | |||
| 31 | return next(action); // eslint-disable-line consistent-return |
||
| 32 | }; |
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.